--申请护送美女的对话

 
--#include "data\config\activityconfig\Dart\DartConfig.lua"  once  --基本设置
--#include "data\functions\Activity\Dart\ApplyDartCommon.lua" once


local npcId = 1
NpcDialog[npcId] = {}

--对话npc
NpcDialog[npcId].main = function(sysarg)
	local dlgStr = ""
	if Actor.checkActorLevel(sysarg, EscortDartConfig.LevelLimit) then
		dlgStr = string.format("%s\n<#BL%s/@ActorApplyDart>", dlgStr, Lang.Activity.t00070)
	end
	local sVar = Actor.getStaticVar(sysarg)
	if not sVar.ybstate then	--正在押送镖车
		sVar.ybstate = 0
	end
	if sVar.ybstate == 1 then
		dlgStr = string.format("%s\n<#BL%s/@GiveUpApplyDart>", dlgStr, Lang.Activity.t00071)
	end
	return dlgStr
end

--护送美女
NpcDialog[npcId].ActorApplyDart = function(sysarg)
	local dVar = Actor.getDyanmicVar(sysarg)
	local var = Actor.getStaticVar(sysarg)
	if not var.days then var.days = {} end
	if not var.ybstate then	--正在押送镖车
		var.ybstate = 0
	end	
	if var.ybstate == 1 then
		Actor.sendTipmsg( sysarg, Lang.Activity.t00072,ttFlyTip)
		return
	end

	if not Actor.checkActorLevel(sysarg,EscortDartConfig.LevelLimit) then
		Actor.sendTipmsg( sysarg, string.format(Lang.Activity.t00073,EscortDartConfig.LevelLimit),ttFlyTip)
		return
	end

	if not var.days.darttms then
		var.days.darttms = 0 
	end
	
	local nTimes = EscortDartConfig.OpenTimes		--能护送的次数
	if Actor.isVip(sysarg) then
		nTimes = EscortDartConfig.VipOpenTimes
	end

	if var.days.darttms >= nTimes then		--护送的次数
		if Actor.hasQuest(sysarg, EscortDartConfig.DartQuestId) and not Actor.canFinishQuest(sysarg, EscortDartConfig.DartQuestId) then
		else
			if not Actor.isVip(sysarg) then
				local pack = DataPack.allocPacket(sysarg, 145, 9)
				DataPack.flush(pack)
			else
				OpenGuideUi(sysarg)
				Actor.sendTipmsg( sysarg, Lang.Activity.t00074,ttFlyTip)
			end
			return
		end
	end
	
	StartApplyActorDart(sysarg, 0)
	
	Actor.setWorkDayMask(sysarg, 0, 13, true)

	Actor.closeNPCDialog(sysarg)
end

--放弃护送
NpcDialog[npcId].GiveUpApplyDart = function(sysarg)
	return string.format("%s\n<#BL%s/@OnGiveUpDart>\n<#BL%s/@OnCancleGiveUp>", Lang.Activity.g00029,Lang.Activity.g00006, Lang.Activity.g00007)
end

NpcDialog[npcId].OnGiveUpDart = function(sysarg)
	ResetActorDartInfo(sysarg, false, true)
	Actor.closeNPCDialog(sysarg)
end

NpcDialog[npcId].OnCancleGiveUp = function(sysarg)
	Actor.closeNPCDialog(sysarg)
end